﻿CREATE Procedure [dbo].[GetUserOrder]
As
Begin

	select 
		u.[Id]
		,u.[Name]
		,u.[Email]
		,u.[ZipCode]
		,u.[Phone]
		,u.[IsContactedByPhone]
		,so.[Name] as SinkOptionName
		,so.[Description] as SinkOptionDescription
		,so.[ImagePath] as SinkOptionImagePath
		,pt.[Name] as ProjectTypeName
		,pt.[Description] as ProjectTypeDescription
		,pt.[ImagePath] as ProjectTypeImagePath
		,pu.[Name] as ProjectUrgencyName
		,pu.[Description] as ProjectUrgencyDescription
		,pu.[ImagePath] as ProjectUrgencyImagePath
		,e.[Name] as EdgeName
		,e.[Description] as EdgeDescription
		,e.[Thumbnail] as EdgeThumbnail
		,e.[ImagePath] as EdgeImagePath
		,e.[Price] as EdgePrice
		,s.[Name] as StoneName
		,s.[Description] as StoneDescription
		,s.[Thumbnail] as StoneThumbnail
		,s.[ImagePath] as StoneImagePath
		,st.[Name] as StoneTypeName
		,st.[Description] as StoneTypeDescription
		,st.[ImagePath] as StoneTypeImagePath
		,sc.[Name] as StoneCategoryName
		,sc.[Description] as StoneCategoryDescription
		,sc.[ImagePath] as StoneCategoryImagePath
		,s.Price as StonePrice
	from dbo.[user] as u
	left join dbo.[UserOptions] as uo on u.[Id] = uo.[UserId]
	left join dbo.[UserCost] as uc on u.[Id] = uc.[UserId]
	left join dbo.[SinkOption] as so on so.[SinkOptionId] = uo.[SinkOptionId]
	left join dbo.[ProjectType] as pt on pt.[ProjectTypeId] = uo.[ProjectTypeId]
	left join dbo.[ProjectUrgency] as pu on pu.[ProjectUrgencyId] = uo.[ProjectUrgencyId]
	left join dbo.[Edge] as e on e.[Id] = uo.[EdgeId]
	left join dbo.[Stone] as s on s.[Id] = uo.[StoneId]
	left join dbo.[StoneType] as st on st.[StoneTypeId] = s.[StoneTypeId]
	left join dbo.[StoneCategory] as sc on sc.[StoneCategoryId] = s.[StoneCategoryId]
	where 
		u.[IsActive] = 1
--		and so.[IsActive] = 1
--		and pt.[IsActive] = 1
--		and pu.[IsActive] = 1
--		and e.[IsActive] = 1
--		and s.[IsActive] = 1
--		and st.[IsActive] = 1
--		and sc.[IsActive] = 1

End